﻿@{
    Layout = null;
}
@model Freshbox2._0.MODEL.welcome
<!DOCTYPE html>

<html>
<head>
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="icon" type="image/gif" href="~/img/animated_favicon1.gif">
    <meta name="viewport" content="width=device-width" />
    <link href="~/UILibs/easyui/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/UILibs/easyui/themes/icon.css" rel="stylesheet" />
    <link href="~/Css/css.css" rel="stylesheet" />

    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/UILibs/easyui/jquery.easyui.min.js"></script>
    <script src="~/UILibs/easyui/locale/easyui-lang-zh_CN.js"></script>

    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
    <title></title>
    <script type="text/javascript">
        $(function () {

            $('#storeid').combobox({
                valueField: "StoreID", //Value字段 
                textField: "StoreName", //Text字段                 
                url: "/PresellWares/GetStore", //数据源 
            });

            $("#data").datagrid({
                fit: true,
                title: 'APP端结算台界面管理',
                striped: true,
                rownumbers: true,
                columns:
                    [[{
                        field: 'ck',
                        checkbox: true
                    }, {
                        field: 'welcome_id',  //welcome_id  welcome_imgurl
                        title: '编号',
                        width: 150,
                        height: 50,
                        halign: 'center',
                        sortable: true,
                        align: 'center'
                    }, {
                        field: 'welcome_imgurl',
                        title: '图片路径',
                        width: 150,
                        height: 50,
                        halign: 'center',
                        align: 'center',
                        formatter: function (value, row) {
                            var str = "";
                            if (value != "" || value != null) {
                                str = "<img style=\"height: 50px;width: 100px;\" src=\"" + value + "\"/>";  //网络图片可以  本地图片不知道
                                return str;
                            }
                        }
                    }, {
                        field: 'storeid',
                        title: '店铺',
                        width: 300,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }]],
                url: pageConfig.getAction,
                pagination: true,
                pageSize: 10,
                pageList: [10, 15, 20, 25],
                sortName: 'welcome_id',
                sortOrder: 'desc',
                toolbar: '#tool'
            });

            $("#formdialog").dialog({
                width: 400,
                height: 250,
                closed: true,
                modal: true,
                buttons: '#btns'
            });

        });

        var pageConfig = {
            type: null,
            getAction: '@Url.Action("Get")',
            saveAction: '@Url.Action("Save")',
            delAction: '@Url.Action("ModifyState")',
            modifyAction: '@Url.Action("Modify")',
            getOneAction: '@Url.Action("GetOnlyOne")',
        };

        function alertFormDialog(type) {
            $("#formdialog form").form("reset");
            if (type == 1) {
                $("#trImg").hide();
                $("#formdialog").dialog("open");
                $("#formdialog").dialog("setTitle", "添加");
                $("#formdialog form").attr("action", pageConfig.saveAction);
            }
            else {

                var rows = $("#data").datagrid("getSelections");
                if (rows.length != 1) {
                    $.messager.alert("提示", "修改时必须且只能选中一条记录！", "info");
                }
                else {
                    $("#formdialog").dialog("open");
                    $("#formdialog").dialog("setTitle", "修改");
                    $('#adminUsername').attr("disabled", true);//不可编辑
                    $.ajax({
                        async: false,
                        url: pageConfig.getOneAction + "?id=" + rows[0].welcome_id,
                        dataType: "json",
                        type: "POST",
                        success: function (data) {
                            // alert(data.welcome_imgurl);
                            $("#formdialog input[name='welcome_id']").val(data.welcome_id);
                            $("#welcome_imgurl").attr("src", data.welcome_imgurl)


                        }
                    });
                }
            }
        }
        function app() {
            $("#imgContainer").append("<div style=\"margin-top:10px;\">" +
                "<input type=\"file\" name=\"file\" />" +
            "<input type=\"button\" value=\"删除\" onclick=\"delfile(this)\" />" +
            "<input type=\"button\" value=\"上移\" onclick=\"up(this)\" />" +
            "<input type=\"button\" value=\"下移\" onclick=\"down(this)\" />" +
            "</div>");
        }

        function CheckPost() {
            return
            true;
        }

    </script>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%">
    <div data-options="region:'center'">
        <table id="data"></table>

        <div id="tool" style="padding: 10px;">
            <div style="margin-bottom: 10px;">
                <div style="margin-bottom: 10px;">
                    &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                    <a class="easyui-linkbutton" iconcls="icon-add" style="width: 100px; height: 50px;" onclick="alertFormDialog(1)">添加人员</a> &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                    <a class="easyui-linkbutton" iconcls="icon-edit" style="width: 100px; height: 50px;" onclick="alertFormDialog(2)">修改密码</a> &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                    <a class="easyui-linkbutton" iconcls="icon-remove" style="width: 100px; height: 50px;" onclick="del()">禁用用户</a>
                    &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                用户名：<input id="txtName" style="width: 180px; height: 25px; margin-top: 15px" type="text" oninput="searchData()" />
                    &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                <a class="easyui-linkbutton" iconcls="icon-search" onclick="searchData()">查询</a>
                </div>
            </div>
        </div>
    </div>

    <div id="formdialog">


        <form enctype="multipart/form-data" method="post" id="frm" action="/TestPicture/UploadImg" onsubmit="return CheckPost()">
            @Html.HiddenFor(x => x.welcome_id)
            <table class="tk_table">
                <tr>
                    <td>屏幕图片：
                    </td>
                    <td>
                        <input type="button" value="添加图片" onclick="app();" id="btnInsertImg" />
                        <span style="color: red" id="spanPicture"></span>
                    </td>
                </tr>
                <tr id="trImg">

                    <td>
                        <img id="welcome_imgurl" height="100" width="100" />
                    </td>

                </tr>

                <tr>
                    <td>店铺：
                    </td>
                    <td>
                        <input class="easyui-combobox" id="storeid" style="height: 30px; width: 200px" data-options="required:true" /></td>
                </tr>
            </table>
            <div id="imgContainer">
            </div>
            <input class="item_submit" type="submit" name="Submit" value="提交">
            <input class="item_submit" type="button" value="关闭" onclick="not();" />
        </form>

    </div>

</body>
</html>

<style>
    .item_submit {
        background-color: #2EA2ED;
        width: 60px;
        height: 30px;
        font-size: 16px;
        color: white;
        font-weight: bold;
        border-radius: 10px;
        margin-right: 50px;
        margin-top: 120px;
    }
</style>


